package com.atguigu.gmall.all.controller.api;

import com.atguigu.gmall.item.client.feign.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author wk
 * @create 2021-08-30 20:37
 * 商品详情页面渲染
 */
@Controller
@RequestMapping
public class ItemController {
    @Resource
    private ItemFeignClient itemFeignClient;

    // 商品详情页面
    @GetMapping("{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model) {
        Map map = itemFeignClient.getItem(skuId);
        model.addAllAttributes(map);
        return "item/index";
    }
}
